<template>

  <el-dialog 
      :title="props.title" 
      v-model="show"
      @open="resetInput"
      :close-on-click-modal="false"
      :close-on-press-escape="false">
    <el-input v-model="inputValue" placeholder="请输入名称" @keydown.enter.native="submitInput"></el-input>
    <template #footer>
      <div class="dialog-footer">
        <el-button  type="info" @click="closeDialog()">取消</el-button>
        <el-button type="primary" @click="submitInput()">确定</el-button>
      </div>
    </template>
  </el-dialog>
  
</template>
  
  <script setup>
  import { ref } from 'vue';
  
  // 接收父组件传递的 props
  const props = defineProps({
    title: {
      type: String,
      required: true,
    }
  });


const resetInput = () => {
  inputValue.value = '';
};

const emit = defineEmits(['submitInput',]);
const submitInput = () => {
  emit('submitInput', inputValue.value);
};
  // 关闭弹窗
const closeDialog = () => {
  show.value = false
};


const show  = ref(false)
const inputValue = ref('')
defineExpose({
  show,
  inputValue
})
</script>
  
<style scoped>

</style>
  